<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
	<head>
		<title>Table Columns</title>
<link href="../docs-assets/Breadcrumbs.css" rel="stylesheet" rev="stylesheet" type="text/css">
		<meta name="viewport" content="width=device-width initial-scale=1">
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
		<meta http-equiv="Content-Language" content="en-gb">

<link href="../docs-assets/Contents.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Progress.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Navigation.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Fonts.css" rel="stylesheet" rev="stylesheet" type="text/css">
<link href="../docs-assets/Base.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
function togglePopup(material_id) {
  var popup = document.getElementById(material_id);
  popup.classList.toggle("show");
}
</script>

<link href="../docs-assets/Popups.css" rel="stylesheet" rev="stylesheet" type="text/css">
<script>
MathJax = {
	tex: {
		inlineMath: '$', '$'], ['\\(', '\\)'
	},
	svg: {
		fontCache: 'global'
	}
};
</script>
<script type="text/javascript" id="MathJax-script" async
	src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-svg.js">
</script>

<link href="../docs-assets/Colours.css" rel="stylesheet" rev="stylesheet" type="text/css">
		
	</head>
	<body class="commentary-font">
		<nav role="navigation">
		<h1><a href="../index.html"><img src="../docs-assets/Inform.png" height=72> </a></h1>
<ul><li><a href="../index.html">home</a></li>
</ul><h2>Compiler</h2><ul>
<li><a href="../structure.html">structure</a></li>
<li><a href="../inbuildn.html">inbuild</a></li>
<li><a href="../inform7n.html">inform7</a></li>
<li><a href="../intern.html">inter</a></li>
<li><a href="../services.html">services</a></li>
<li><a href="../secrets.html">secrets</a></li>
</ul><h2>Other Tools</h2><ul>
<li><a href="../inblorbn.html">inblorb</a></li>
<li><a href="../inform6.html">inform6</a></li>
<li><a href="../inpolicyn.html">inpolicy</a></li>
</ul><h2>Resources</h2><ul>
<li><a href="../extensions.html">extensions</a></li>
<li><a href="../kits.html">kits</a></li>
</ul><h2>Repository</h2><ul>
<li><a href="https://github.com/ganelson/inform"><img src="../docs-assets/github.png" height=0> github</a></li>
</ul><h2>Related Projects</h2><ul>
<li><a href="https://github.com/ganelson/inweb"><img src="../docs-assets/github.png" height=0> inweb</a></li>
<li><a href="https://github.com/ganelson/intest"><img src="../docs-assets/github.png" height=0> intest</a></li>
</ul>
		</nav>
		<main role="main">
		<!-- Weave of 'Table Columns' generated by inweb -->
<div class="breadcrumbs">
    <ul class="crumbs"><li><a href="../index.html">Home</a></li><li><a href="../inform7n.html">Inform7</a></li><li><a href="index.html">assertions</a></li><li><a href="index.html#7">Chapter 7: Other Gadgets</a></li><li><b>Table Columns</b></li></ul></div>
<p class="purpose">To manage the named columns which appear in tables.</p>

<ul class="toc"><li><a href="7-tc.html#SP4">&#167;4. Creation</a></li><li><a href="7-tc.html#SP6">&#167;6. Kind</a></li><li><a href="7-tc.html#SP7">&#167;7. Discovering columns</a></li><li><a href="7-tc.html#SP13">&#167;13. Checking kind consistency</a></li></ul><hr class="tocbar">

<p class="commentary firstcommentary"><a id="SP1" class="paragraph-anchor"></a><b>&#167;1. </b>Tables are one of the most distinctive data structures of Inform. They
imitate printed tables in books or scientific papers, and the data inside
them is arranged in columns, each of which is headed by a name.
</p>

<p class="commentary">Data in a given column must have a definite kind, such as "number". Where
this is unspecified in any explicit way, it is inferred by performing a
join on the kinds of the values quoted in the column &mdash; that is, the result
is the narrowest kind capable of holding all of the observed values.
</p>

<p class="commentary">Inform has a limited ability to link tables together, as in a relational
database, but this relies on an unusual design decision: if a column in
two different tables has the same name, then it must have the same kind
in both tables.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">table_column</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">noun</span><span class="plain-syntax"> *</span><span class="identifier-syntax">name</span><span class="plain-syntax">; </span><span class="comment-syntax"> name of column (without "entry" suffix)</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">kind_stored_in_column</span><span class="plain-syntax">; </span><span class="comment-syntax"> what kind of value is stored in this column</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">table_from_which_kind_inferred</span><span class="plain-syntax">; </span><span class="comment-syntax"> usually the earliest use</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="identifier-syntax">listed_in_predicate</span><span class="plain-syntax">; </span><span class="comment-syntax"> see below</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">table_column_compilation_data</span><span class="plain-syntax"> </span><span class="identifier-syntax">compilation_data</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">CLASS_DEFINITION</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">table_column</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure table_column is accessed in 3/nuor, 3/dbtr, 3/rpr, 4/ass, 5/id, 5/idf, 5/adf, 5/tpf, 5/po, 5/rf, 5/rcd, 6/rls, 6/rlb, 6/fao, 6/act, 6/sv, 7/tbl, 7/eqt and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP2" class="paragraph-anchor"></a><b>&#167;2. </b>The predicate calculus engine often finds conditions equivalent to "if A
is a C listed in T", and we implement this as a binary predicate &mdash; see
<a href="8-lr.html" class="internal">Listed-In Relations</a>. There is one such relation for each column, and
a pointer is stored in <span class="extract"><span class="extract-syntax">listed_in_predicate</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">binary_predicate</span><span class="plain-syntax"> *</span><span class="function-syntax">Tables::Columns::get_listed_in_predicate</span><span class="plain-syntax">(</span><span class="reserved-syntax">table_column</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tc</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">listed_in_predicate</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP3" class="paragraph-anchor"></a><b>&#167;3. </b></p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Tables::Columns::log</span><button class="popup" onclick="togglePopup('usagePopup1')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup1">Usage of <span class="code-font"><span class="function-syntax">Tables::Columns::log</span></span>:<br/>Assertions Module - <a href="1-am.html#SP2">&#167;2</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">table_column</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tc</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"'%W'/"</span><span class="plain-syntax">, </span><span class="identifier-syntax">Nouns::nominative_singular</span><span class="plain-syntax">(</span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">name</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kind_stored_in_column</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"unknown"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"%u"</span><span class="plain-syntax">, </span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kind_stored_in_column</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP4" class="paragraph-anchor"></a><b>&#167;4. Creation.</b>Columns are created with a name, which is assumed here to be not the name
of any existing column.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">table_column</span><span class="plain-syntax"> *</span><span class="function-syntax">Tables::Columns::new_table_column</span><button class="popup" onclick="togglePopup('usagePopup2')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup2">Usage of <span class="code-font"><span class="function-syntax">Tables::Columns::new_table_column</span></span>:<br/><a href="7-tc.html#SP12_2">&#167;12.2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">table_column</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">CREATE</span><span class="plain-syntax">(</span><span class="reserved-syntax">table_column</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kind_stored_in_column</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">table_from_which_kind_inferred</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::nonempty</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)) { </span><span class="comment-syntax"> always happens unless recovering from a problem</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">name</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Nouns::new_proper_noun</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">NEUTER_GENDER</span><span class="plain-syntax">, </span><span class="identifier-syntax">ADD_TO_LEXICON_NTOPT</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">TABLE_COLUMN_MC</span><span class="plain-syntax">, </span><span class="identifier-syntax">Rvalues::from_table_column</span><span class="plain-syntax">(</span><span class="identifier-syntax">tc</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Task::language_of_syntax</span><span class="plain-syntax">());</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">word_assemblage</span><span class="plain-syntax"> </span><span class="identifier-syntax">wa</span><span class="plain-syntax"> =</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">PreformUtilities::merge</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;table-column-name-construction&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">0</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">WordAssemblages::from_wording</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">));</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">AW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">WordAssemblages::to_wording</span><span class="plain-syntax">(&amp;</span><span class="identifier-syntax">wa</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Nouns::new_proper_noun</span><span class="plain-syntax">(</span><span class="identifier-syntax">AW</span><span class="plain-syntax">, </span><span class="identifier-syntax">NEUTER_GENDER</span><span class="plain-syntax">, </span><span class="identifier-syntax">ADD_TO_LEXICON_NTOPT</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">TABLE_COLUMN_MC</span><span class="plain-syntax">, </span><span class="identifier-syntax">Rvalues::from_table_column</span><span class="plain-syntax">(</span><span class="identifier-syntax">tc</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Task::language_of_syntax</span><span class="plain-syntax">());</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">compilation_data</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RTTableColumns::new_compilation_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">tc</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">listed_in_predicate</span><span class="plain-syntax"> = </span><a href="8-lr.html#SP2" class="function-link"><span class="function-syntax">Tables::Relations::make_listed_in_predicate</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">tc</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">tc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP5" class="paragraph-anchor"></a><b>&#167;5. </b>The author can demand with a "translates as" sentence that a given
table should have an identifier given to it which is accessible to Inter:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Tables::Columns::translates</span><button class="popup" onclick="togglePopup('usagePopup3')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup3">Usage of <span class="code-font"><span class="function-syntax">Tables::Columns::translates</span></span>:<br/>Translation Requests - <a href="3-tr.html#SP9_1_2">&#167;9.1.2</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">p2</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;s-value&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">table_column</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Rvalues::to_table_column</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tc</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">RTTableColumns::translate</span><span class="plain-syntax">(</span><span class="identifier-syntax">tc</span><span class="plain-syntax">, </span><span class="identifier-syntax">Node::get_text</span><span class="plain-syntax">(</span><span class="identifier-syntax">p2</span><span class="plain-syntax">));</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOG</span><span class="plain-syntax">(</span><span class="string-syntax">"Tried %W\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::sentence_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">Task::syntax_tree</span><span class="plain-syntax">(),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TranslatesNonTableColumn</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="string-syntax">"this is not the name of a table column"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"so cannot be translated."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6" class="paragraph-anchor"></a><b>&#167;6. Kind.</b>Keeping track of the kind of the entries in a column is a little tricky.
Columns are created early in Inform's run, before the full hierarchy of kinds
is in place; so TC structures tend to record a <span class="extract"><span class="extract-syntax">NULL</span></span> kind for a while, and
are then corrected later. Moreover, they're sometimes revised in the light
of evidence, if the kind has to be inferred from the table's initial entries.
So we can't just set the kind once at creation time.
</p>

<p class="commentary">This has a knock-on effect on the predicate associated with the column,
because the kind of term \(A\) in \({\it listed}_C(A, T)\) must match the kind
of entry in the column \(C\).
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="function-syntax">Tables::Columns::get_kind</span><button class="popup" onclick="togglePopup('usagePopup4')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup4">Usage of <span class="code-font"><span class="function-syntax">Tables::Columns::get_kind</span></span>:<br/><a href="7-tc.html#SP13">&#167;13</a>, <a href="7-tc.html#SP14">&#167;14</a>, <a href="7-tc.html#SP15">&#167;15</a><br/>Define by Table Requests - <a href="3-dbtr.html#SP4_2_1">&#167;4.2.1</a><br/>Tables - <a href="7-tbl.html#SP10">&#167;10</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">table_column</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tc</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kind_stored_in_column</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>

<span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="function-syntax">Tables::Columns::to_kind</span><span class="plain-syntax">(</span><span class="reserved-syntax">table_column</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tc</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">Kinds::unary_con</span><span class="plain-syntax">(</span><span class="identifier-syntax">CON_table_column</span><span class="plain-syntax">, </span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kind_stored_in_column</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>

<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Tables::Columns::set_kind</span><button class="popup" onclick="togglePopup('usagePopup5')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup5">Usage of <span class="code-font"><span class="function-syntax">Tables::Columns::set_kind</span></span>:<br/><a href="7-tc.html#SP12">&#167;12</a>, <a href="7-tc.html#SP13">&#167;13</a>, <a href="7-tc.html#SP14">&#167;14</a>, <a href="7-tc.html#SP15">&#167;15</a><br/>Define by Table Requests - <a href="3-dbtr.html#SP4_1">&#167;4.1</a>, <a href="3-dbtr.html#SP4_2_1">&#167;4.2.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">table_column</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tc</span><span class="plain-syntax">, </span><span class="reserved-syntax">table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::get_construct</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">) == </span><span class="identifier-syntax">CON_description</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="named-paragraph-container code-font"><a href="7-tc.html#SP6_1" class="named-paragraph-link"><span class="named-paragraph">Issue a problem message for a description heading</span><span class="named-paragraph-number">6.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kind_stored_in_column</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">TABLES</span><span class="plain-syntax">, </span><span class="string-syntax">"Table column $C continues to have kind %u, according to $B\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tc</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">t</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">TABLES</span><span class="plain-syntax">, </span><span class="string-syntax">"Table column $C set to kind %u, according to $B\n"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tc</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">t</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kind_stored_in_column</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">table_from_which_kind_inferred</span><span class="plain-syntax"> = </span><span class="identifier-syntax">t</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">K_understanding</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">Kinds::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_understanding</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">        </span><a href="8-lr.html#SP3" class="function-link"><span class="function-syntax">Tables::Relations::supply_kind_for_listed_in_tc</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">listed_in_predicate</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_snippet</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><a href="8-lr.html#SP3" class="function-link"><span class="function-syntax">Tables::Relations::supply_kind_for_listed_in_tc</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">tc</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">listed_in_predicate</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP6_1" class="paragraph-anchor"></a><b>&#167;6.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem message for a description heading</span><span class="named-paragraph-number">6.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_kind</span><span class="plain-syntax">(4, </span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_kind</span><span class="plain-syntax">(5, </span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_table</span><span class="plain-syntax">(6, </span><span class="identifier-syntax">t</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TableColumnDescription</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">tc</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"In %1, you've written the heading of the column '%2' to say that each entry "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"should be %4. But descriptions aren't allowed as table entries - tables "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"have to hold values, not descriptions of values."</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-tc.html#SP6">&#167;6</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP7" class="paragraph-anchor"></a><b>&#167;7. Discovering columns.</b>New TCs aren't declared ("Density is a table column."): they are discovered
by looking through the column-heading lines of tables. Each one makes:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">typedef</span><span class="plain-syntax"> </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">table_column_usage</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="reserved-syntax">table_column</span><span class="plain-syntax"> *</span><span class="identifier-syntax">column_identity</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">entries</span><span class="plain-syntax">; </span><span class="comment-syntax"> initial contents of this column in the table</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind_declaration_text</span><span class="plain-syntax">; </span><span class="comment-syntax"> if specified</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">actual_constant_entries</span><span class="plain-syntax">; </span><span class="comment-syntax"> how many entries have explicitly been given</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">observed_constant_cell</span><span class="plain-syntax">; </span><span class="comment-syntax"> first one spotted</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">kind_name_entries</span><span class="plain-syntax">; </span><span class="comment-syntax"> how many entries read, say, "a rulebook"</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">observed_kind_cell</span><span class="plain-syntax">; </span><span class="comment-syntax"> first one spotted</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">struct</span><span class="plain-syntax"> </span><span class="identifier-syntax">table_column_usage_compilation_data</span><span class="plain-syntax"> </span><span class="identifier-syntax">compilation_data</span><span class="plain-syntax">;</span>
<span class="plain-syntax">} </span><span class="reserved-syntax">table_column_usage</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>The structure table_column_usage is accessed in 3/nuor, 3/dbtr, 5/id, 5/idf, 5/adf, 5/tpf, 5/rf, 5/rcd, 6/rls, 6/rlb, 6/fao, 6/act, 7/tbl, 7/eqt and here.</li></ul>
<p class="commentary firstcommentary"><a id="SP8" class="paragraph-anchor"></a><b>&#167;8. </b>Each piece of heading text is passed to the following routine in turn:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">table_column_usage</span><span class="plain-syntax"> </span><span class="function-syntax">Tables::Columns::add_to_table</span><button class="popup" onclick="togglePopup('usagePopup6')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup6">Usage of <span class="code-font"><span class="function-syntax">Tables::Columns::add_to_table</span></span>:<br/>Tables - <a href="7-tbl.html#SP18_9_1">&#167;18.9.1</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="reserved-syntax">table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">t</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">EXPW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">table_column_usage</span><span class="plain-syntax"> </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">table_column</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tc</span><span class="plain-syntax"> = </span><a href="7-tc.html#SP12" class="function-link"><span class="function-syntax">Tables::Columns::find_table_column</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="identifier-syntax">t</span><span class="plain-syntax">, &amp;</span><span class="identifier-syntax">EXPW</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">for</span><span class="plain-syntax"> (</span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">=0; </span><span class="identifier-syntax">i</span><span class="function-syntax">&lt;t-&gt;</span><span class="element-syntax">no_columns</span><span class="plain-syntax">; </span><span class="identifier-syntax">i</span><span class="plain-syntax">++)</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">t</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">columns</span><span class="plain-syntax">[</span><span class="identifier-syntax">i</span><span class="plain-syntax">].</span><span class="element-syntax">column_identity</span><span class="plain-syntax"> == </span><span class="identifier-syntax">tc</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(4, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_DuplicateColumnName</span><span class="plain-syntax">),</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">,</span>
<span class="plain-syntax">                </span><span class="string-syntax">"In %1, the column name %4 cannot be used, because there's already "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"a column of the same name. (You can't have two columns with the "</span>
<span class="plain-syntax">                </span><span class="string-syntax">"same name in the same table.)"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">.</span><span class="element-syntax">column_identity</span><span class="plain-syntax"> = </span><span class="identifier-syntax">tc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">.</span><span class="element-syntax">entries</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Diagrams::new_PROPER_NOUN</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">.</span><span class="element-syntax">kind_declaration_text</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EXPW</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">.</span><span class="element-syntax">actual_constant_entries</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">.</span><span class="element-syntax">observed_constant_cell</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">.</span><span class="element-syntax">kind_name_entries</span><span class="plain-syntax"> = </span><span class="constant-syntax">0</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">.</span><span class="element-syntax">observed_kind_cell</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">.</span><span class="element-syntax">compilation_data</span><span class="plain-syntax"> = </span><span class="identifier-syntax">RTTables::new_tcu_compilation_data</span><span class="plain-syntax">(</span><span class="identifier-syntax">t</span><span class="plain-syntax">);</span>

<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP9" class="paragraph-anchor"></a><b>&#167;9. </b>The syntax for table column headings is little complicated:
</p>

<pre class="definitions code-font"><span class="definition-keyword">define</span> <span class="constant-syntax">EXISTING_TC</span><span class="plain-syntax"> </span><span class="constant-syntax">1</span><span class="plain-syntax">               </span><span class="comment-syntax"> one seen before in another table, with a kind given</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">EXISTING_TC_WITHOUT_KIND</span><span class="plain-syntax"> </span><span class="constant-syntax">2</span><span class="plain-syntax">  </span><span class="comment-syntax"> one seen before in another table</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">NEW_TC</span><span class="plain-syntax"> </span><span class="constant-syntax">3</span><span class="plain-syntax">                    </span><span class="comment-syntax"> never seen before, with a kind explicitly given</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">NEW_TC_WITHOUT_KIND</span><span class="plain-syntax"> </span><span class="constant-syntax">4</span><span class="plain-syntax">       </span><span class="comment-syntax"> never seen before, with no specified kind</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">NEW_TC_TOPIC</span><span class="plain-syntax"> </span><span class="constant-syntax">5</span><span class="plain-syntax">              </span><span class="comment-syntax"> a topic column, a specialised form of text</span>
<span class="definition-keyword">define</span> <span class="constant-syntax">NEW_TC_PROBLEM</span><span class="plain-syntax"> </span><span class="constant-syntax">6</span><span class="plain-syntax">            </span><span class="comment-syntax"> (something went wrong, so Inform can ignore this)</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10" class="paragraph-anchor"></a><b>&#167;10. </b>The heading of a table column is the text in its entry in the first
(titling-only) row of the table. Usually that consists only of the column's
name, but optionally the kind can also be supplied in brackets &mdash; Inform
otherwise infers the kind from the contents below. The kind will subsequently
be parsed using <span class="extract"><span class="extract-syntax">&lt;k-kind-articled&gt;</span></span>, but for timing reasons that happens later,
so the grammar below allows any text in the brackets. A "topic" column
needs special handling since it also overrides kind inference, making
what looks like text into grammar for parsing.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;table-column-heading&gt;</span>
<span class="plain-syntax">    ( *** ) |</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">topic</span><span class="plain-syntax"> ( ... ) |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;s-table-column-name&gt;</span><span class="plain-syntax"> ( {...} ) |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;table-column-heading-bare&gt;</span><span class="plain-syntax"> ( {...} ) |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;s-table-column-name&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;table-column-heading-bare&gt;</span>

<span class="function-syntax">&lt;table-column-heading-bare&gt;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;article&gt;</span><span class="plain-syntax"> |</span>
<span class="plain-syntax">    {</span><span class="identifier-syntax">topic</span><span class="plain-syntax">} |</span>
<span class="plain-syntax">    {</span><span class="function-syntax">&lt;property-name&gt;</span><span class="plain-syntax">} |</span>
<span class="plain-syntax">    {</span><span class="function-syntax">&lt;s-constant-value&gt;</span><span class="plain-syntax">} |</span>
<span class="plain-syntax">    ...</span>
</pre>
<p class="commentary firstcommentary"><a id="SP10_1" class="paragraph-anchor"></a><b>&#167;10.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_TableColumnArticle problem</span><span class="named-paragraph-number">10.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(4, </span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TableColumnArticle</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">table_being_examined</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">table_cell_node</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"In %1, the column name %3 cannot be used, because there would be too "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"much ambiguity arising from its ordinary meaning as an article. (It "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"would be quite awkward talking about the '%4 entry', for example.)"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    ==&gt; { </span><span class="constant-syntax">NEW_TC_PROBLEM</span><span class="plain-syntax">, - };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-tc.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10_2" class="paragraph-anchor"></a><b>&#167;10.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_TableColumnAlready problem</span><span class="named-paragraph-number">10.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TableColumnAlready</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">table_being_examined</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">table_cell_node</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"In %1, the column name %3 cannot be used, because it already means "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"something else."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    ==&gt; { </span><span class="constant-syntax">NEW_TC_PROBLEM</span><span class="plain-syntax">, - };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-tc.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10_3" class="paragraph-anchor"></a><b>&#167;10.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_TopicText problem</span><span class="named-paragraph-number">10.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TopicText</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">table_being_examined</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">table_cell_node</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"In %1, the column name 'topic' is not allowed to have a clarifying kind "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"in brackets after it. Just say 'topic' and leave it at that."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    ==&gt; { </span><span class="constant-syntax">NEW_TC_PROBLEM</span><span class="plain-syntax">, - };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-tc.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP10_4" class="paragraph-anchor"></a><b>&#167;10.4. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue PM_TableColumnBracketed problem</span><span class="named-paragraph-number">10.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TableColumnBracketed</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">table_being_examined</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">table_cell_node</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"In %1, the column name %3 cannot be used, because it is in brackets. "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"(Perhaps you intended to use the brackets to give the kind of the "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"entries, but forgot to put a name before the opening bracket.)"</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    ==&gt; { </span><span class="constant-syntax">NEW_TC_PROBLEM</span><span class="plain-syntax">, - };</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-tc.html#SP10">&#167;10</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP11" class="paragraph-anchor"></a><b>&#167;11. </b>When a column is found with a name not seen before &mdash; say, "merit points"
&mdash; the following grammar is used to construct a proper noun to refer to this
column; thus, "merit points column".
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="function-syntax">&lt;table-column-name-construction&gt;</span>
<span class="plain-syntax">    ... </span><span class="identifier-syntax">column</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12" class="paragraph-anchor"></a><b>&#167;12. </b>And here's where we use the grammar above. We parse the heading text and
return the TC it refers to, creating it if necessary; and we also return the
text of any explicit kind declaration used within it.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">table_column</span><span class="plain-syntax"> *</span><span class="function-syntax">Tables::Columns::find_table_column</span><button class="popup" onclick="togglePopup('usagePopup7')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup7">Usage of <span class="code-font"><span class="function-syntax">Tables::Columns::find_table_column</span></span>:<br/><a href="7-tc.html#SP8">&#167;8</a></span></button><span class="plain-syntax">(</span><span class="identifier-syntax">wording</span><span class="plain-syntax"> </span><span class="identifier-syntax">W</span><span class="plain-syntax">, </span><span class="reserved-syntax">table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">wording</span><span class="plain-syntax"> *</span><span class="identifier-syntax">EXPW</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">table_cell_node</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Diagrams::new_PROPER_NOUN</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">table_cell_row</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">table_cell_col</span><span class="plain-syntax"> = -1;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">table_being_examined</span><span class="plain-syntax"> = </span><span class="identifier-syntax">t</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    *</span><span class="identifier-syntax">EXPW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="function-syntax">&lt;table-column-heading&gt;</span><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">table_column</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">switch</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;&lt;r&gt;&gt;</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">EXISTING_TC_WITHOUT_KIND:</span>
<span class="plain-syntax">            *</span><span class="identifier-syntax">EXPW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Wordings::new</span><span class="plain-syntax">(-1, -1);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Rvalues::to_table_column</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">EXISTING_TC:</span>
<span class="plain-syntax">            *</span><span class="identifier-syntax">EXPW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">GET_RW</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;table-column-heading&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">tc</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Rvalues::to_table_column</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">NEW_TC_TOPIC:</span><span class="plain-syntax"> </span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K_understanding</span><span class="plain-syntax">; </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">NEW_TC:</span><span class="plain-syntax"> *</span><span class="identifier-syntax">EXPW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">GET_RW</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;table-column-heading&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">); </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">NEW_TC_WITHOUT_KIND:</span><span class="plain-syntax"> </span><span class="reserved-syntax">break</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">case</span><span class="plain-syntax"> </span><span class="identifier-syntax">NEW_TC_PROBLEM:</span><span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="named-paragraph-container code-font"><a href="7-tc.html#SP12_1" class="named-paragraph-link"><span class="named-paragraph">Make a try at identifying the any named kind, even though it probably won't work</span><span class="named-paragraph-number">12.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tc</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="named-paragraph-container code-font"><a href="7-tc.html#SP12_2" class="named-paragraph-link"><span class="named-paragraph">Create a new table column with this name</span><span class="named-paragraph-number">12.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">K</span><span class="plain-syntax">) </span><a href="7-tc.html#SP6" class="function-link"><span class="function-syntax">Tables::Columns::set_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">tc</span><span class="plain-syntax">, </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">tc</span><span class="plain-syntax">;</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP12_1" class="paragraph-anchor"></a><b>&#167;12.1. </b>If the heading is something like "population (number)", the following will
correctly identify "number", because that's a kind which exists very early in
Inform's run. Something like "lucky charm (thing)" won't work, because "thing"
hasn't been created yet; but we'll catch it later.
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Make a try at identifying the any named kind, even though it probably won't work</span><span class="named-paragraph-number">12.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">K</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">Wordings::nonempty</span><span class="plain-syntax">(*</span><span class="identifier-syntax">EXPW</span><span class="plain-syntax">)) &amp;&amp; (</span><span class="function-syntax">&lt;k-kind-articled&gt;</span><span class="plain-syntax">(*</span><span class="identifier-syntax">EXPW</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">; *</span><span class="identifier-syntax">EXPW</span><span class="plain-syntax"> = </span><span class="identifier-syntax">EMPTY_WORDING</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-tc.html#SP12">&#167;12</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP12_2" class="paragraph-anchor"></a><b>&#167;12.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Create a new table column with this name</span><span class="named-paragraph-number">12.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">W</span><span class="plain-syntax"> = </span><span class="identifier-syntax">GET_RW</span><span class="plain-syntax">(</span><span class="function-syntax">&lt;table-column-heading-bare&gt;</span><span class="plain-syntax">, </span><span class="constant-syntax">1</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><a href="4-tc.html#SP7" class="function-link"><span class="function-syntax">Assertions::Creator::vet_name</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">)) </span><span class="identifier-syntax">tc</span><span class="plain-syntax"> = </span><a href="7-tc.html#SP4" class="function-link"><span class="function-syntax">Tables::Columns::new_table_column</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">W</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">return</span><span class="plain-syntax"> </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-tc.html#SP12">&#167;12</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP13" class="paragraph-anchor"></a><b>&#167;13. Checking kind consistency.</b>Well, and now it's later. First, the following is called on each usage of a
column in turn:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Tables::Columns::check_explicit_headings</span><button class="popup" onclick="togglePopup('usagePopup8')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup8">Usage of <span class="code-font"><span class="function-syntax">Tables::Columns::check_explicit_headings</span></span>:<br/>Tables - <a href="7-tbl.html#SP20">&#167;20</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="reserved-syntax">table_column_usage</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><a href="7-tc.html#SP6" class="function-link"><span class="function-syntax">Tables::Columns::get_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Wordings::nonempty</span><span class="plain-syntax">(</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kind_declaration_text</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">EK</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="function-syntax">&lt;k-kind-articled&gt;(tcu-&gt;</span><span class="element-syntax">kind_declaration_text</span><span class="plain-syntax">)) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">EK</span><span class="plain-syntax"> = </span><span class="function-syntax">&lt;&lt;rp&gt;&gt;</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">TABLES</span><span class="plain-syntax">, </span><span class="string-syntax">"$B col %d '%W' claims %u\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kind_declaration_text</span><span class="plain-syntax">, </span><span class="identifier-syntax">EK</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">K</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><a href="7-tc.html#SP6" class="function-link"><span class="function-syntax">Tables::Columns::set_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">, </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">EK</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (!(</span><span class="identifier-syntax">Kinds::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">EK</span><span class="plain-syntax">)))</span>
<span class="plain-syntax">                </span><span class="named-paragraph-container code-font"><a href="7-tc.html#SP13_1" class="named-paragraph-link"><span class="named-paragraph">Issue a problem message for a heading inconsistency</span><span class="named-paragraph-number">13.1</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="named-paragraph-container code-font"><a href="7-tc.html#SP13_2" class="named-paragraph-link"><span class="named-paragraph">Issue a problem message for an incomprehensible column heading</span><span class="named-paragraph-number">13.2</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">TABLES</span><span class="plain-syntax">, </span><span class="string-syntax">"Column %d has no explicit kind named in $B\n"</span><span class="plain-syntax">, </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">t</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP13_1" class="paragraph-anchor"></a><b>&#167;13.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem message for a heading inconsistency</span><span class="named-paragraph-number">13.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_kind</span><span class="plain-syntax">(4, </span><span class="identifier-syntax">EK</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_kind</span><span class="plain-syntax">(5, </span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_table</span><span class="plain-syntax">(6, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">table_from_which_kind_inferred</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TableColumnInconsistent</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entries</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"In %1, you've written the heading of the column %3 to say that each entry "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"should be %4. But a column with the same name also appears in %6, and each "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"entry there is %5. Inform doesn't allow this - the same column name always "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"has to have the same kind of entry, whichever tables it appears in."</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-tc.html#SP13">&#167;13</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP13_2" class="paragraph-anchor"></a><b>&#167;13.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem message for an incomprehensible column heading</span><span class="named-paragraph-number">13.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TableColumnBrackets</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entries</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"In %1, I can't use the column heading %3. Brackets are only allowed in "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"table column names when giving the kind of value which will be stored in "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"the column. So 'poems (text)' is legal, but not 'poems (chiefly lyrical)'."</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-tc.html#SP13">&#167;13</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP14" class="paragraph-anchor"></a><b>&#167;14. </b>Secondly, the actual entries are checked in turn, and their kinds passed
to the following routine. Again, "topic" columns are a complication, since
their kind is ostensibly <span class="extract"><span class="extract-syntax">K_understanding</span></span> but the actual entries must be
<span class="extract"><span class="extract-syntax">K_text</span></span>.
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Tables::Columns::note_kind</span><button class="popup" onclick="togglePopup('usagePopup9')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup9">Usage of <span class="code-font"><span class="function-syntax">Tables::Columns::note_kind</span></span>:<br/>Tables - <a href="7-tbl.html#SP23">&#167;23</a>, <a href="7-tbl.html#SP23_1">&#167;23.1</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="reserved-syntax">table_column_usage</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">,</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">parse_node</span><span class="plain-syntax"> *</span><span class="identifier-syntax">cell</span><span class="plain-syntax">, </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">generic</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">generic</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kind_name_entries</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">observed_kind_cell</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">observed_kind_cell</span><span class="plain-syntax"> = </span><span class="identifier-syntax">cell</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kind_name_entries</span><span class="plain-syntax"> == </span><span class="constant-syntax">2</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="named-paragraph-container code-font"><a href="7-tc.html#SP14_2" class="named-paragraph-link"><span class="named-paragraph">Issue a problem for a second kind name in the column</span><span class="named-paragraph-number">14.2</span></a></span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">actual_constant_entries</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="named-paragraph-container code-font"><a href="7-tc.html#SP14_1" class="named-paragraph-link"><span class="named-paragraph">Issue a problem for a kind name lower in the column than a value</span><span class="named-paragraph-number">14.1</span></a></span>
<span class="plain-syntax">        </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">CK</span><span class="plain-syntax"> = </span><a href="7-tc.html#SP6" class="function-link"><span class="function-syntax">Tables::Columns::get_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">CK</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><a href="7-tc.html#SP6" class="function-link"><span class="function-syntax">Tables::Columns::set_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">, </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">return</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">CK</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><span class="named-paragraph-container code-font"><a href="7-tc.html#SP14_6" class="named-paragraph-link"><span class="named-paragraph">Issue a problem for an inconsistent kind for this column</span><span class="named-paragraph-number">14.6</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">actual_constant_entries</span><span class="plain-syntax">++;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">observed_constant_cell</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">observed_constant_cell</span><span class="plain-syntax"> = </span><span class="identifier-syntax">cell</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">kind_name_entries</span><span class="plain-syntax"> &gt; </span><span class="constant-syntax">0</span><span class="plain-syntax">)</span>
<span class="plain-syntax">            </span><span class="named-paragraph-container code-font"><a href="7-tc.html#SP14_3" class="named-paragraph-link"><span class="named-paragraph">Issue a problem for a value lower in the column than a kind name</span><span class="named-paragraph-number">14.3</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">CK</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Kinds::weaken</span><span class="plain-syntax">(</span><a href="7-tc.html#SP6" class="function-link"><span class="function-syntax">Tables::Columns::get_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">), </span><span class="identifier-syntax">K_object</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Kinds::weaken</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_object</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">global_pass_state</span><span class="plain-syntax">.</span><span class="element-syntax">pass</span><span class="plain-syntax"> &gt;= </span><span class="constant-syntax">2</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">CK</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">Kinds::Behaviour::definite</span><span class="plain-syntax">(</span><span class="identifier-syntax">CK</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">))</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">CK</span><span class="plain-syntax"> = </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">;</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">CK</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><a href="7-tc.html#SP6" class="function-link"><span class="function-syntax">Tables::Columns::set_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">, </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    } </span><span class="reserved-syntax">else</span><span class="plain-syntax"> {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">allow_refinement</span><span class="plain-syntax"> = </span><span class="identifier-syntax">TRUE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">K_understanding</span><span class="plain-syntax">) &amp;&amp; (</span><span class="identifier-syntax">Kinds::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">CK</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_understanding</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">CK</span><span class="plain-syntax"> = </span><span class="identifier-syntax">K_text</span><span class="plain-syntax">; </span><span class="comment-syntax"> make sure the entries are texts...</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">allow_refinement</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">; </span><span class="comment-syntax"> ...and don't allow any change to the kind</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">CK</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">max_K</span><span class="plain-syntax"> = </span><span class="identifier-syntax">Latticework::join</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">CK</span><span class="plain-syntax">);</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">Kinds::Behaviour::definite</span><span class="plain-syntax">(</span><span class="identifier-syntax">max_K</span><span class="plain-syntax">) == </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Problems::quote_kind</span><span class="plain-syntax">(4, </span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">Problems::quote_kind</span><span class="plain-syntax">(5, </span><span class="identifier-syntax">CK</span><span class="plain-syntax">);</span>
<span class="plain-syntax">                </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">t</span><span class="plain-syntax"> == </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">table_from_which_kind_inferred</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                    </span><span class="named-paragraph-container code-font"><a href="7-tc.html#SP14_4" class="named-paragraph-link"><span class="named-paragraph">Issue a problem for kind mismatch within column</span><span class="named-paragraph-number">14.4</span></a></span>
<span class="plain-syntax">                </span><span class="reserved-syntax">else</span>
<span class="plain-syntax">                    </span><span class="named-paragraph-container code-font"><a href="7-tc.html#SP14_5" class="named-paragraph-link"><span class="named-paragraph">Issue a problem for kind mismatch between columns of the same name</span><span class="named-paragraph-number">14.5</span></a></span><span class="plain-syntax">;</span>
<span class="plain-syntax">                </span><span class="identifier-syntax">allow_refinement</span><span class="plain-syntax"> = </span><span class="identifier-syntax">FALSE</span><span class="plain-syntax">;</span>
<span class="plain-syntax">            }</span>
<span class="plain-syntax">            </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">allow_refinement</span><span class="plain-syntax">)</span>
<span class="plain-syntax">                </span><a href="7-tc.html#SP6" class="function-link"><span class="function-syntax">Tables::Columns::set_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">, </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">max_K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        }</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<p class="commentary firstcommentary"><a id="SP14_1" class="paragraph-anchor"></a><b>&#167;14.1. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem for a kind name lower in the column than a value</span><span class="named-paragraph-number">14.1</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">quoted_col</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">; </span><span class="comment-syntax"> i.e., counting from 1</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_number</span><span class="plain-syntax">(4, &amp;</span><span class="identifier-syntax">quoted_col</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_number</span><span class="plain-syntax">(5, &amp;</span><span class="identifier-syntax">table_cell_row</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(6, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">observed_constant_cell</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TableKindBelowValue</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">, </span><span class="identifier-syntax">cell</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"In %1, column %4 (%2), the entry %3 (row %5) is the name of a kind. "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"This isn't a specific value. You're allowed to write in the name "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"of a kind like this if the column otherwise has blank entries - to "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"tell Inform what might eventually go there - but here the column "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"already contains a genuine value higher up: %6. %P"</span>
<span class="plain-syntax">        </span><span class="string-syntax">"So the kind name has to go. You can either let me deduce the kind by "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"myself, working it out from the actual values in the column, or you "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"can put the kind in brackets after the column's name, at the top.)"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-tc.html#SP14">&#167;14</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP14_2" class="paragraph-anchor"></a><b>&#167;14.2. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem for a second kind name in the column</span><span class="named-paragraph-number">14.2</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">quoted_col</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">; </span><span class="comment-syntax"> i.e., counting from 1</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_number</span><span class="plain-syntax">(4, &amp;</span><span class="identifier-syntax">quoted_col</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_number</span><span class="plain-syntax">(5, &amp;</span><span class="identifier-syntax">table_cell_row</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(6, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">observed_kind_cell</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TableKindTwice</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">, </span><span class="identifier-syntax">cell</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"In %1, column %4 (%2), the entry %3 (row %5) is the name of a kind. "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"This isn't a specific value. You're allowed to write in the name "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"of a kind like this if the column starts out with blank entries - to "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"tell me what might eventually go there - but only once; and "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"this is the second time. (The first was %6.)"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-tc.html#SP14">&#167;14</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP14_3" class="paragraph-anchor"></a><b>&#167;14.3. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem for a value lower in the column than a kind name</span><span class="named-paragraph-number">14.3</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">quoted_col</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">; </span><span class="comment-syntax"> i.e., counting from 1</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_number</span><span class="plain-syntax">(4, &amp;</span><span class="identifier-syntax">quoted_col</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_number</span><span class="plain-syntax">(5, &amp;</span><span class="identifier-syntax">table_cell_row</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_source</span><span class="plain-syntax">(6, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">observed_kind_cell</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TableValueBelowKind</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">, </span><span class="identifier-syntax">cell</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"In %1, column %4 (%2), the entry %3 (row %5) is a genuine, non-blank "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"entry: it's a specific value. That's fine, of course - the whole "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"idea of a table is to contain values - but this is a column which "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"already contains a name of a kind: %6. %P"</span>
<span class="plain-syntax">        </span><span class="string-syntax">"Names of kinds are only allowed at the top of otherwise blank columns: "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"they tell me what might eventually go there. So the kind name has to go. "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"You can replace it with a blank '--', and then either let me deduce the "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"kind by myself, working it out from the actual values in the column, or "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"you can put the kind in brackets after the column's name, at the top.)"</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-tc.html#SP14">&#167;14</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP14_4" class="paragraph-anchor"></a><b>&#167;14.4. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem for kind mismatch within column</span><span class="named-paragraph-number">14.4</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">quoted_col</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">; </span><span class="comment-syntax"> i.e., counting from 1</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_number</span><span class="plain-syntax">(6, &amp;</span><span class="identifier-syntax">quoted_col</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_number</span><span class="plain-syntax">(7, &amp;</span><span class="identifier-syntax">table_cell_row</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TableIncompatibleEntry</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">, </span><span class="identifier-syntax">cell</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"In %1, column %6 (%2), the entry %3 (row %7) doesn't fit what I know "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"about '%2' - it's %4, whereas I think every entry ought to be %5."</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-tc.html#SP14">&#167;14</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP14_5" class="paragraph-anchor"></a><b>&#167;14.5. </b><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem for kind mismatch between columns of the same name</span><span class="named-paragraph-number">14.5</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">quoted_col</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">; </span><span class="comment-syntax"> i.e., counting from 1</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_table</span><span class="plain-syntax">(6, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">table_from_which_kind_inferred</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(7, </span><span class="identifier-syntax">Nouns::nominative_singular</span><span class="plain-syntax">(</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">name</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_number</span><span class="plain-syntax">(8, &amp;</span><span class="identifier-syntax">quoted_col</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_number</span><span class="plain-syntax">(9, &amp;</span><span class="identifier-syntax">table_cell_row</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TableIncompatibleEntry2</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">, </span><span class="identifier-syntax">cell</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"In %1, column %8 (%2), the entry %3 (row %9) has the wrong kind to be in "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"the '%2' column - it's %4, whereas I think every entry ought to be %5. %P"</span>
<span class="plain-syntax">        </span><span class="string-syntax">"The entries under a given column name must be blanks or values of the same "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"kind as each other, and this applies even to columns in different tables "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"if they have the same name. Compare the table %6, where there's also a "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"column called '%7'."</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-tc.html#SP14">&#167;14</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP14_6" class="paragraph-anchor"></a><b>&#167;14.6. </b>Relatedly, but visible only if there are no entries so that the above never
happens:
</p>

<p class="commentary"><span class="named-paragraph-container code-font"><span class="named-paragraph-defn">Issue a problem for an inconsistent kind for this column</span><span class="named-paragraph-number">14.6</span></span><span class="comment-syntax"> =</span>
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_table</span><span class="plain-syntax">(6, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">table_from_which_kind_inferred</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_wording</span><span class="plain-syntax">(7, </span><span class="identifier-syntax">Nouns::nominative_singular</span><span class="plain-syntax">(</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">name</span><span class="plain-syntax">));</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_kind</span><span class="plain-syntax">(4, </span><span class="identifier-syntax">K</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">Problems::quote_kind</span><span class="plain-syntax">(5, </span><span class="identifier-syntax">CK</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TableColumnIncompatible</span><span class="plain-syntax">),</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">, </span><span class="identifier-syntax">cell</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="string-syntax">"In %1, the column '%2' is declared as holding %4, but when the same "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"column appeared in table %6, the contents were said there to be %5. %P"</span>
<span class="plain-syntax">        </span><span class="string-syntax">"The entries under a given column name must be values of the same "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"kind as each other, and this applies even to columns in different tables "</span>
<span class="plain-syntax">        </span><span class="string-syntax">"if they have the same name."</span><span class="plain-syntax">);</span>
</pre>
<ul class="endnotetexts"><li>This code is used in <a href="7-tc.html#SP14">&#167;14</a>.</li></ul>
<p class="commentary firstcommentary"><a id="SP15" class="paragraph-anchor"></a><b>&#167;15. </b>Thirdly and lastly:
</p>

<pre class="displayed-code all-displayed-code code-font">
<span class="reserved-syntax">void</span><span class="plain-syntax"> </span><span class="function-syntax">Tables::Columns::approve_kind</span><button class="popup" onclick="togglePopup('usagePopup10')"><span class="comment-syntax">?</span><span class="popuptext" id="usagePopup10">Usage of <span class="code-font"><span class="function-syntax">Tables::Columns::approve_kind</span></span>:<br/>Tables - <a href="7-tbl.html#SP20">&#167;20</a></span></button><span class="plain-syntax">(</span><span class="reserved-syntax">table</span><span class="plain-syntax"> *</span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="reserved-syntax">table_column_usage</span><span class="plain-syntax"> *</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">kind</span><span class="plain-syntax"> *</span><span class="identifier-syntax">K</span><span class="plain-syntax"> = </span><a href="7-tc.html#SP6" class="function-link"><span class="function-syntax">Tables::Columns::get_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="identifier-syntax">LOGIF</span><span class="plain-syntax">(</span><span class="identifier-syntax">TABLES</span><span class="plain-syntax">, </span><span class="string-syntax">"Column %d '%W' has kind %u with data:\n$T"</span><span class="plain-syntax">,</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">i</span><span class="plain-syntax">, </span><span class="identifier-syntax">Nouns::nominative_singular</span><span class="plain-syntax">(</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">name</span><span class="plain-syntax">), </span><span class="identifier-syntax">K</span><span class="plain-syntax">, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entries</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> ((</span><span class="identifier-syntax">Kinds::get_construct</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">) == </span><span class="identifier-syntax">CON_list_of</span><span class="plain-syntax">) &amp;&amp;</span>
<span class="plain-syntax">        (</span><span class="identifier-syntax">Kinds::eq</span><span class="plain-syntax">(</span><span class="identifier-syntax">Kinds::unary_construction_material</span><span class="plain-syntax">(</span><span class="identifier-syntax">K</span><span class="plain-syntax">), </span><span class="identifier-syntax">K_nil</span><span class="plain-syntax">))) {</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TableColumnEmptyLists</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">entries</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"In %1, the column %3 seems to consist only of empty lists. "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"This means that I can't tell what kind of value it should hold - "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"are they to be lists of numbers, for instance, or lists of texts, "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"or some other possibility? Either one of the entries must contain a "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"non-empty list - so that I can deduce the answer by looking at what "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"is in it - or else the column heading must say, e.g., by calling it "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"'exceptions (list of texts)' with the kind of value in brackets after "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"the name."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">    </span><span class="reserved-syntax">if</span><span class="plain-syntax"> (</span><span class="identifier-syntax">K</span><span class="plain-syntax"> == </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">) {</span>
<span class="plain-syntax">        </span><span class="reserved-syntax">int</span><span class="plain-syntax"> </span><span class="identifier-syntax">quoted_col</span><span class="plain-syntax"> = </span><span class="identifier-syntax">i</span><span class="plain-syntax"> + </span><span class="constant-syntax">1</span><span class="plain-syntax">; </span><span class="comment-syntax"> i.e., counting from 1</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">Problems::quote_number</span><span class="plain-syntax">(4, &amp;</span><span class="identifier-syntax">quoted_col</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><span class="identifier-syntax">StandardProblems::table_problem</span><span class="plain-syntax">(</span><span class="identifier-syntax">_p_</span><span class="plain-syntax">(</span><span class="identifier-syntax">PM_TableKindlessColumn</span><span class="plain-syntax">),</span>
<span class="plain-syntax">            </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">, </span><span class="identifier-syntax">NULL</span><span class="plain-syntax">,</span>
<span class="plain-syntax">            </span><span class="string-syntax">"Column %4 (%2) of %1 contains no values and doesn't tell me "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"anything about its kind%S.%L, "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"which means that I don't know how to deal with it. You should "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"either put a value into the column somewhere, or else write "</span>
<span class="plain-syntax">            </span><span class="string-syntax">"the kind in as part of the heading: '%2 (a number)', say."</span><span class="plain-syntax">);</span>
<span class="plain-syntax">        </span><a href="7-tc.html#SP6" class="function-link"><span class="function-syntax">Tables::Columns::set_kind</span></a><span class="plain-syntax">(</span><span class="identifier-syntax">tcu</span><span class="plain-syntax">-&gt;</span><span class="element-syntax">column_identity</span><span class="plain-syntax">, </span><span class="identifier-syntax">t</span><span class="plain-syntax">, </span><span class="identifier-syntax">K_number</span><span class="plain-syntax">);</span>
<span class="plain-syntax">    }</span>
<span class="plain-syntax">}</span>
</pre>
<nav role="progress"><div class="progresscontainer">
    <ul class="progressbar"><li class="progressprev"><a href="6-sv.html">&#10094;</a></li><li class="progresschapter"><a href="P-wtmd.html">P</a></li><li class="progresschapter"><a href="1-am.html">1</a></li><li class="progresschapter"><a href="2-bv.html">2</a></li><li class="progresschapter"><a href="3-dlr.html">3</a></li><li class="progresschapter"><a href="4-nr.html">4</a></li><li class="progresschapter"><a href="5-id.html">5</a></li><li class="progresschapter"><a href="6-rls.html">6</a></li><li class="progresscurrentchapter">7</li><li class="progresscurrent">tc</li><li class="progresssection"><a href="7-tbl.html">tbl</a></li><li class="progresssection"><a href="7-eqt.html">eqt</a></li><li class="progresschapter"><a href="8-kpr.html">8</a></li><li class="progressnext"><a href="7-tbl.html">&#10095;</a></li></ul></div>
</nav><!-- End of weave -->

		</main>
	</body>
</html>

